/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jsalon.web.controller;

import static jamjun.infra.web.CHelper.MappingRequestToObj;
import jamjun.infra.web.Content;
import jamjun.infra.web.Controller;
import jamjun.infra.web.GSession;
import jamjun.infra.web.Result;
import jamjun.infra.web.View;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jsalon.model.Officer;
import jsalon.web.vm.CustomerVM;
import jsalon.web.vm.OfficerVM;

/**
 *
 * @author Java
 */
@WebServlet(name = "officer", urlPatterns = {"/officer"})
public class OfficerController extends Controller {

    public static Result index()
    {
        OfficerVM viewModel = new OfficerVM();
        jsalon.model.Officer data = new Officer();
        viewModel.officer = data;
        return new View("/View/Officer/index.jsp",viewModel);
    }
    
    public static Result List()
    {
        CustomerVM viewModel = new CustomerVM();
        jsalon.model.Customer customer = new jsalon.model.Customer();
        List<jsalon.model.Officer> customerList = new ArrayList<jsalon.model.Officer>();
        try {
            //<editor-fold desc="mapping Model.">
            customer = MappingRequestToObj(customer,"data",GSession.getRequest());
            //customerList = CHelper.MappingRequestToObjList(customer,"data", GSession.getRequest());
            //customerList = MappingRequestToObjList
            viewModel.customer = customer;
            //</editor-fold>
        } catch (Exception ex) {
            Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
            return new Content(ex.getMessage());
        }        
        return new View("/View/Officer/index.jsp",viewModel);
    }
    
    public static Result Detail()
    {
        CustomerVM viewModel = new CustomerVM();
        jsalon.model.Customer customer = new jsalon.model.Customer();
        List<jsalon.model.Officer> customerList = new ArrayList<jsalon.model.Officer>();
        try {
            //<editor-fold desc="mapping Model.">
            customer = MappingRequestToObj(customer,"data",GSession.getRequest());
            //customerList = CHelper.MappingRequestToObjList(customer,"data", GSession.getRequest());
            //customerList = MappingRequestToObjList
            viewModel.customer = customer;
            //</editor-fold>
        } catch (Exception ex) {
            Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
            return new Content(ex.getMessage());
        }        
        return new View("/View/Officer/index.jsp",viewModel);
    }

}
